<!--显示链接-->
<div class="module_movie_uri">
    <div class="resolution" id="resolution">
        <ul>
            <li><a href="#1080p" data-resolution="1080p" id="resolution_1080p">1080p</a></li>
            <li><a href="#720p" data-resolution="720p" id="resolution_720p">720p</a></li>
            <li><a href="#480p" data-resolution="480p" id="resolution_480p">480p</a></li>
        </ul>
        <script>
attachEventChooseResolution();
        </script>
        <div class="clear"></div>
    </div>
<?php
$uri = array();
foreach($v['movie_uri'] as $one) {
    $uri[$one['resolution']][] = $one;
}
$map = array(
    'free_genuine_download' => '免费正版下载',
    'chargeable_genuine_download' => '收费正版下载',
    'free_direct_download' => '免费下载',
);
foreach($uri as $k=>$one_resolution_uris) {
    $download = array(
        'free_genuine_download' => array(),
        'chargeable_genuine_download' => array(),
        'free_direct_download' => array(),
    );
    foreach($one_resolution_uris as $one) {
        if(($one['is_free'] == 1) && ($one['is_genuine'] == 1)) {
            $download['free_genuine_download'][] = $one;
        }
        if(($one['is_free'] == 0) && ($one['is_genuine'] == 1)) {
            $download['chargeable_genuine_download'][] = $one;
        }
        if(($one['is_free'] == 1) && ($one['is_direct_download'] == 1)) {
            $download['free_direct_download'][] = $one;
        }
    }
    echo '<div class="uri_at_one_resolution" id="uri_' . $v['resolution'][$k] . '">' . "\n";
    if(!empty($download['free_genuine_download'])) {
        echo '<div class="no_direct_download"><p>免费正版下载：</p><div class="download_uri"><ul>';
        foreach($download['free_genuine_download'] as $one) {
            echo '<li><a href="' . $one['uri'] . '" target="_blank">' . $v['providers'][$one['provider_id']] . '</a></li>' . "\n";
        }
        echo '</ul><div class="clear"></div></div><div class="clear"></div></div>' . "\n";
    }
    if(!empty($download['chargeable_genuine_download'])) {
        echo '<div class="no_direct_download"><p>收费正版下载：</p><div class="download_uri"><ul>' . "\n";
        foreach($download['chargeable_genuine_download'] as $one) {
            echo '<li><a href="' . $one['uri'] . '" target="_blank">' . $v['providers'][$one['provider_id']] . '</a></li>' . "\n";
        }
        echo '</ul><div class="clear"></div></div><div class="clear"></div></div>' . "\n";
    }
    
    //如果有免费下载
    if(!empty($download['free_direct_download'])) {
        echo '<div class="direct_download"><p>免费下载：</p>' . "\n";
        echo '<p class="copyright_notice">';
        if(!empty($download['free_genuine_download'])) {
            echo '如果你已下载了以上的免费正版，则拥有下载观看权。';
        } else {
            if (!empty($download['free_genuine_download'])) {
                echo '如果你已购买了以上的收费正版，则拥有下载观看权。';
            } else {
                echo '尚未有公司购买正版免费提供给大家，请购买：<a target="_blank" href="http://z.alimama.com/tksEss.php?q=' . rawurlencode('正版 蓝光 ' . $v['movie']['name']) . '&cat=0&pid=mm_23145895_3402037_10952556&unid=&stid=1&commend=all&search_type=auction&user_action=initiative&f=D9_5_1&at_topsearch=1&sid=%2869417ff315c63438b67f245bcf3a8d8b%29&sort=&spercent=0&st=0">' . '正版 蓝光 ' . $v['movie']['name'] . '</a>';
            }
        }
        echo '</p>';
        if(empty($download['free_genuine_download'])) {
            echo '<div>'; //todo hidden
        } else {
            echo '<div>';
        }
        echo '<p class="notice">迅雷支持BT，但不支持PT，推荐使用<a href="http://www.utorrent.com/downloads/complete/os/win/track/stable" target="_blank">µTorrent</a>或<a href="http://xf.qq.com/" target="_blank">QQ旋风</a>。</p>';
        foreach($download['free_direct_download'] as $one) {
            if(in_array(strtolower($v['providers'][$one['provider_id']]), array('pt', 'bt'))) {
                $files = json_decode($one['torrent']['files'], true);
                echo '<div class="files">' . "\n"; //如果是电视剧就有很多集
                echo '<ul>' . "\n";
                foreach($files as $name=>$size) {
                    echo '<li>' . $name . ' ' . FileLib::formatFilesize($size) . '</li>' . "\n";
                }
                echo '</ul>' . "\n";
                echo '</div>' . "\n";
                echo '<div class="download_uri">' . "\n";
                if(strtolower($v['providers'][$one['provider_id']]) == 'pt') {
                echo '<ul>'; //有PT时一定有BT
//                echo '<li><a href="' . $one['bt_uri'] . '" " target="_blank">BT</a></li>' . "\n";
                echo '<li><a title="登录后即可下载" class="uri_pt_disable" data-href="' . $one['uri'] . '" href="#" target="_blank">' . $v['providers'][$one['provider_id']] . '</a></li>' . "\n";
                echo '</ul><div class="clear"></div>' . "\n";
                } else {
                echo '<li><a class="uri_' . strtolower($v['providers'][$one['provider_id']]) . '" href="' . $one['uri'] . '" target="_blank">' . $v['providers'][$one['provider_id']] . '</a></li>' . "\n";
                }
                echo '</div><div class="clear"></div>' . "\n";
            }
            //todo ed2k
        }
        echo '</div><div class="clear"></div></div>' . "\n";
    }
    echo '</div>' . "\n";
}
;?>
<script>
actionChooseResolution(actionGetResolution());
attachEventDisablePtUri();
actionShowPtUri();
actionShowFreeDirectDownload();
</script>
    </div>
</div>
